/*
 * T.Raynal - A.Aviles - F.Diallo
 * XML-Scenarios
 * PPA AL5-2
 * December 2012 
 */
package model.expression;

import java.io.Serializable;

import common.Commons.EXPRESSION_TYPE;
import common.Commons.OPERATORS;
import common.Commons.RESULT;
import common.exception.UnsupportedOperatorException;
import common.interfaces.IEvaluable;
import common.OperatorRegister;

import model.Expression;
import model.Operator;
import model.serialization.XmlSerializable;
import model.serialization.XmlElement;

// TODO: Auto-generated Javadoc
/**
 * Represent a logical expression
 */
@XmlElement(name = "EXPRESSION")
public class LogicalExpression extends Expression implements IEvaluable, XmlSerializable, Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * Instantiates a new logical expression.
	 *
	 * @param Label
	 * @param Result
	 */
	@SuppressWarnings("serial")
	public LogicalExpression(String label, String result) {
		super(label, result,EXPRESSION_TYPE.LOGICAL, 
				new EvaluateeHandler() {
			@Override
			public boolean valid(String evaluatee) {
				boolean result =true;	
				if (null==evaluatee)
					result= false;
					return result;
			}
		}	
		);
		_register = OperatorRegister.getOperators(OPERATORS.LOGICAL);
		_resultType = RESULT.ALPHANUMERIC;
	}
	
	/* (non-Javadoc)
	 * @see model.Expression#register(model.Operator)
	 */
	public void register (Operator operator) throws UnsupportedOperatorException
	{
		if (operator.getType()==OPERATORS.DYNAMIC || operator.getType()==OPERATORS.DYNAMIC)
			throw new UnsupportedOperatorException(operator.getId());
		super.register(operator);
	}
	

}
